package com.teamAwesome.nfcAlarm;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

public class DayslistActivity extends Activity {

    protected CharSequence[] _options = { "Monday", "Tuesday", "Wednesday",
	    "Thursday", "Friday", "Saturday", "Sunday" };
    protected boolean[] _selections = new boolean[_options.length];

    protected Button _optionsButton;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	setContentView(R.layout.alarm_settings);

	_optionsButton = (Button) findViewById(R.id.alarmbutton);
	_optionsButton.setOnClickListener(new ButtonClickHandler());
    }

    public class ButtonClickHandler implements View.OnClickListener {
	public void onClick(View view) {
	    showDialog(0);
	}
    }

    @Override
    protected Dialog onCreateDialog(int id) {
	return new AlertDialog.Builder(this)
		.setTitle("Days")
		.setMultiChoiceItems(_options, _selections,
			new DialogSelectionClickHandler())
		.setPositiveButton("OK", new DialogButtonClickHandler())
		.create();
    }

    public class DialogSelectionClickHandler implements
	    DialogInterface.OnMultiChoiceClickListener {
	public void onClick(DialogInterface dialog, int clicked,
		boolean selected) {
	    Log.i("ME", _options[clicked] + " selected: " + selected);
	}
    }

    public class DialogButtonClickHandler implements
	    DialogInterface.OnClickListener {
	public void onClick(DialogInterface dialog, int clicked) {
	    switch (clicked) {
	    case DialogInterface.BUTTON_POSITIVE:
		printSelectedDays();
		break;
	    }
	}
    }

    protected void printSelectedDays() {
	for (int i = 0; i < _options.length; i++) {
	    Log.i("ME", _options[i] + " selected: " + _selections[i]);
	}
    }
}